from page.focus_project_page import FocusProjectPage
from page.common_tools import CommonTools
import random as r
import time as t


class FocusFriendsPage(FocusProjectPage, CommonTools):

    def publish_trends(self):
        self.find_button('发布').click()
        self.find_text_view(
            string='输入内容不超过500字...', attr='value'
        ).send_keys("这是圈子%d的内容。。。。" % r.randint(100, 999))
        # self.find_button('图片').click()
        # self.select_from_album(5)
        self.find_button('相机').click()
        self.find_xpath('//*[@name="PhotoCapture"]').click()  # 拍照
        t.sleep(3)
        self.find_button(string="使用照片", contains_flag=1).click()
        self.find_button(string='发布',contains_flag=1).click()
        t.sleep(8)
        self.find_button(string="我的圈子",contains_flag=1).click()
        self.swipe_dr("down")
        t.sleep(1)


    def trends_comment(self):
        # self.find_static_text(string='这是圈子', contains_flag=1).click()
        self.swipe(170,110,170,110)   #选择我发布的圈子
        self.get_frame_center_and_click(self.find_static_text('写评论...'), flag=0)
        self.find_element(*self.comment_text).send_keys("这是评论的内容。。。。")
        self.find_button("发布").click()
        self.find_button(string="返回", contains_flag=1).click()

    def delete_trends(self):
        self.swipe(170,110,170,110)
        self.find_button(string='删除',contains_flag=1).click()
        self.find_button('删除').click()
        self.find_button(string="common back dark icon",contains_flag=1).click()
        self.find_button(string="common back dark icon", contains_flag=1).click()
        self.find_button(string="数学班", contains_flag=1).click()

if __name__ == "__main__":
    test = FocusFriendsPage()
    test.enter_project()
    test.enter_tools("研修圈")
    test.publish_trends()
    test.publish_trends()
    test.trends_comment()
    test.delete_trends()
